#include <stdlib.h>
#include <memory.h>
#include <stdio.h>

#include "LogicPool/LogicInterfaceUSB.h"
#include "LogicPool/logicbox.h"


void LogicInterfaceUSB::Open()
{
  fd = usbOpen(device);
}


void LogicInterfaceUSB::Close()
{
  usbClose(fd);
  fd = 0;
}


void LogicInterfaceUSB::Reset()
{
  logicReset(fd);
}


uint32_t LogicInterfaceUSB::GetID()
{
  return logicGetID(fd);
}


void LogicInterfaceUSB::SetAddress(uint8_t type, uint8_t number, uint8_t addr)
{
  logicSetAddress(fd, type, number, addr);
}


void LogicInterfaceUSB::SetShortAddress(uint8_t number, uint8_t addr)
{
  logicSetShortAddress(fd, number, addr);
}


uint8_t LogicInterfaceUSB::ReadByte()
{
  return logicReadByte(fd);
}


void LogicInterfaceUSB::WriteByte(uint8_t data)
{
  logicWriteByte(fd, data);
}


uint16_t LogicInterfaceUSB::ReadWord()
{
  return logicReadWord(fd);
}


void LogicInterfaceUSB::ReadWordFIFO(uint16_t * data, uint16_t n)
{
  logicReadWordFIFO(fd, data, n);
}


void LogicInterfaceUSB::WriteWord(uint16_t data)
{
  logicWriteWord(fd, data);
}


uint32_t LogicInterfaceUSB::ReadLong()
{
  return logicReadLong(fd);
}


void LogicInterfaceUSB::WriteLong(uint32_t data)
{
  logicWriteLong(fd, data);
}

